package com.huajiao.management_system.util;


import java.util.LinkedList;
import java.util.List;


/**
 * List分页工具
 */
public class PageQueryUtil extends LinkedList {
    //当前页码
    private int page;
    //每页数据
    private int pageSize;
    //每页的开始数
    private int start;
    //此页显示的数据
    private List pagelist;

    public PageQueryUtil(List list, Integer page) {

        this.page = page;

        //设置每页数据为十条

        this.setPageSize(7);

        this.setStart((this.getPage() - 1) * this.getPageSize());

        //list的大小
        int count = list.size();
        //对list进行截取
        if (this.getStart() > count){

            this.setStart(count);
        }
        this.setPagelist(list.subList(this.getStart(), count - this.getStart() >
                this.getPageSize() ? this.getStart() + this.getPageSize() : count));
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public List getPagelist() {
        return pagelist;
    }

    public void setPagelist(List pagelist) {
        this.pagelist = pagelist;
    }
}

